home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 416_01 / vidstate / vidstate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-12  |  7.2 KB  |  207 lines

  1. /* Print video state table returned by int 10h function 1Bh */
  2. /* (c) Nigel Salt 1991                                      */
  3. /* Microsoft C V6                                           */
  4. /* -------------------------------------------------------- */
  5. #include <dos.h>
  6. #include <stdio.h>
  7. void main(void);
  8.  
  9. #pragma pack(1)
  10. /* Pack pragma needed to avoid padding of vb structure */
  11.  
  12. typedef unsigned int  word;
  13. typedef unsigned char byte;
  14. typedef struct
  15. {
  16.   byte modesupp[7];
  17.   byte scansupp; /* 0,1,2=200,350,400 */
  18.   byte numchblocks;
  19.   byte maxactblocks;
  20.   byte flagsupp;
  21.   byte miscsupp;
  22.   byte res1[2];
  23.   byte flags2supp;
  24.   byte res2;
  25.  
  26. } STATEFUN, far *STATEFUNPTR;
  27.  
  28. struct VIDBUFF
  29. {
  30.   STATEFUNPTR   functabptr;
  31.   byte          vidmode;
  32.   word          numcols;
  33.   word          regenlen;
  34.   word          regenstart;
  35.   byte          curspos[8][2];
  36.   byte          cursflin;
  37.   byte          curselin;
  38.   byte          actpage;
  39.   word          portadd;
  40.   byte          cur3x8;
  41.   byte          cur3x9;
  42.   byte          numrows;
  43.   word          bytesperchar;
  44.   byte          ActDispCombCode;
  45.   byte          AltDispCombCode;
  46.   word          numcolors;
  47.   byte          numpages;
  48.   byte          numscan; /* 0,1,2,3 = 200,350,400,480 */
  49.   byte          primchblock;
  50.   byte          secchblock;
  51.   byte          flags;
  52.     /* 0 always on
  53.        1 gray summing on
  54.        2 mono display attached
  55.        3 default pallette loading disabled
  56.        4 cursor emulation enabled
  57.        5 0=intensity 1=blinking
  58.        6/7 reserved
  59.     */
  60.   char          res1[3];
  61.   byte          vidmem; /* 0,1,2,3 = 64K,128K,192K,256K */
  62.   byte          flags2;
  63.     /* 0 512 char set active
  64.        1 dynamic save present
  65.        2 alpha font override
  66.        3 graphics font override
  67.        4 pallette override
  68.        5 DCC override
  69.        6/7 reserved
  70.     */
  71.   char          res2[13];
  72. } vb;
  73. void main(void)
  74. {
  75.   int i,j;
  76.   word mask;
  77.   union REGS iregs,oregs;
  78.   struct SREGS segregs;
  79.   void far *vbptr;
  80.   vbptr=(void far *)&vb;
  81.   segregs.es=FP_SEG(vbptr);
  82.   iregs.x.di=FP_OFF(vbptr);
  83.   iregs.h.ah=0x1b;
  84.   iregs.x.bx=0;
  85.   int86x(0x10,&iregs,&oregs,&segregs);
  86.   printf("\nVideo state information from int 10h func 1b");
  87.   printf("\nCopyright (c) 1991 Nigel Salt");
  88.   printf("\n=============================");
  89.   printf("\nMode:              \t%u",vb.vidmode);
  90.   printf("\nNumCols:           \t%u",vb.numcols);
  91.   printf("\nRegenLen:          \t%u",vb.regenlen);
  92.   printf("\nCursPos[0]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[0][1],vb.curspos[0][0]);
  93.   printf("\nCursPos[1]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[1][1],vb.curspos[1][0]);
  94.   printf("\nCursPos[2]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[2][1],vb.curspos[2][0]);
  95.   printf("\nCursPos[3]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[3][1],vb.curspos[3][0]);
  96.   printf("\nCursPos[4]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[4][1],vb.curspos[4][0]);
  97.   printf("\nCursPos[5]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[5][1],vb.curspos[5][0]);
  98.   printf("\nCursPos[6]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[6][1],vb.curspos[6][0]);
  99.   printf("\nCursPos[7]:        \t%.3d\t%.3d\t(Row,Col)",vb.curspos[7][1],vb.curspos[7][0]);
  100.   printf("\nCursStart:         \t%u",vb.cursflin);
  101.   printf("\nCursEnd:           \t%u",vb.curselin);
  102.   printf("\nCurrPage:          \t%u",vb.actpage);
  103.   printf("\nPortAdd:           \t%Xh",vb.portadd);
  104.   printf("\n3x8Reg:            \t%u",vb.cur3x8);
  105.   printf("\n3x9Reg:            \t%u",vb.cur3x9);
  106.   printf("\nNumRows:           \t%u",vb.numrows);
  107.   printf("\nBytesPerChar:      \t%u",vb.bytesperchar);
  108.   printf("\nActDispCombCode:   \t%u",vb.ActDispCombCode);
  109.   printf("\nAltDispCombCode:   \t%u",vb.AltDispCombCode);
  110.   printf("\nNumColors:         \t%u",vb.numcolors);
  111.   printf("\nNumPages:          \t%u",vb.numpages);
  112.   printf("\nScanLines          \t");
  113.   switch(vb.numscan)
  114.     {
  115.     case 0:
  116.       printf("200");
  117.       break;
  118.     case 1:
  119.       printf("350");
  120.       break;
  121.     case 2:
  122.       printf("400");
  123.       break;
  124.     case 3:
  125.       printf("480");
  126.       break;
  127.     }
  128.   printf("\nPrimCharBlock:     \t%u",vb.primchblock);
  129.   printf("\nSecCharBlock:      \t%u",vb.secchblock);
  130.  
  131.   printf("\nVideo memory:      \t");
  132.   switch (vb.vidmem)
  133.     {
  134.     case 0:
  135.       printf("64K");
  136.       break;
  137.     case 1:
  138.       printf("128K");
  139.       break;
  140.     case 2:
  141.       printf("192K");
  142.       break;
  143.     case 3:
  144.       printf("256K");
  145.       break;
  146.     case 4:
  147.       printf("512K");
  148.       break;
  149.     case 5:
  150.       printf("1024K");
  151.       break;
  152.     }
  153.   printf("\nFlags:");
  154.   if (vb.flags&2)  printf("\n\tGray summing on");
  155.   if (vb.flags&4)  printf("\n\tMono display attached");
  156.   if (vb.flags&8)  printf("\n\tDefault pallete load disabled");
  157.   if (vb.flags&16) printf("\n\tCursor emulation enabled");
  158.   printf("\n\t%s",(vb.flags&32,"Blinking","intensity"));
  159.   if (vb.flags2&1) printf("\n\t512 char set active");
  160.   if (vb.flags2&2) printf("\n\tDynamic save present");
  161.   if (vb.flags2&4) printf("\n\tAlpha font override");
  162.   if (vb.flags2&8) printf("\n\tGraphics font override");
  163.   if (vb.flags2&16) printf("\n\tPallette override");
  164.   if (vb.flags2&32) printf("\n\tDisplay Comb Code override");
  165.   printf("\n\nState supported table information");
  166.   printf("\n=================================");
  167.   printf("\nModes supported:\n\t");
  168.   for (i=0;i<7;i++)
  169.     {
  170.     mask=1;
  171.     for (j=0;j<8;j++)
  172.       {
  173.       if (vb.functabptr->modesupp[i]&mask)
  174.         printf("%u ",i*8+j);
  175.       mask*=2;
  176.       }
  177.     }
  178.   printf("\nScan lines supported:\n\t");
  179.   if (vb.functabptr->scansupp&1) printf("200 ");
  180.   if (vb.functabptr->scansupp&2) printf("350 ");
  181.   if (vb.functabptr->scansupp&4) printf("400 ");
  182.   if (vb.functabptr->scansupp&8) printf("480 ");
  183.   printf("\nTextModeCharBlocks:\t%u",vb.functabptr->numchblocks);
  184.   printf("\nMaxActCharBlocks:  \t%u",vb.functabptr->maxactblocks);
  185.   printf("\nFlags:");
  186.   if (vb.functabptr->flagsupp&2)  printf("\n\tGray summing supported");
  187.   if (vb.functabptr->flagsupp&4)  printf("\n\tCharacter font loading supported");
  188.   if (vb.functabptr->flagsupp&8)  printf("\n\tDef pallete load enable/disable supported");
  189.   if (vb.functabptr->flagsupp&16) printf("\n\tCursor emulation supported");
  190.   if (vb.functabptr->flagsupp&32) printf("\n\tEGA pallette present");
  191.   if (vb.functabptr->flagsupp&64) printf("\n\tColor pallette present");
  192.   if (vb.functabptr->flagsupp&128) printf("\n\tColor paging supported");
  193.   
  194.   if (vb.functabptr->miscsupp&1)  printf("\n\tLight pen supported");
  195.   if (vb.functabptr->miscsupp&2)  printf("\n\tSave/rest via fun 1Ch supported");
  196.   if (vb.functabptr->miscsupp&4)  printf("\n\tIntensity/blink supported");
  197.   if (vb.functabptr->miscsupp&8)  printf("\n\tDisplay Comb Code supported");
  198.   
  199.   if (vb.functabptr->flags2supp&1)   printf("\n\t512 char set supported");
  200.   if (vb.functabptr->flags2supp&2)   printf("\n\tDynamic save area supported");
  201.   if (vb.functabptr->flags2supp&4)   printf("\n\tAlpha font override supported");
  202.   if (vb.functabptr->flags2supp&8)   printf("\n\tGraphics font override supported");
  203.   if (vb.functabptr->flags2supp&16)  printf("\n\tPallette override supported");
  204.   if (vb.functabptr->flags2supp&32)  printf("\n\tDCC extension supported");
  205.  
  206. }
  207.